//
//  BaseViewController.swift
//  TWeibo
//
//  Created by wtw on 15/7/28.
//  Copyright © 2015年 wtw. All rights reserved.
//

import UIKit

class BaseViewController: UITableViewController,VisitorLoginViewDelegate {

    //用户登录标记
    var userLogon = UserAcount.userLogon
    
    //访客视图属性
    var visitorView: VisitorLoginView?
    
    override func loadView() {
        //根据用户是否登录判断是否替代根视图
        userLogon ? super.loadView() : setupVisitorView()
    }
    
    //设置访客视图
   private func setupVisitorView() {
    visitorView = VisitorLoginView()
    visitorView?.delegate = self
    view = visitorView
    
    
    //添加到导航栏按钮
    navigationItem.leftBarButtonItem = UIBarButtonItem(title:"注册", style: UIBarButtonItemStyle.Plain, target: self, action: "VisitorLoginViewWillRegister")
    navigationItem.rightBarButtonItem = UIBarButtonItem(title:"登录", style: UIBarButtonItemStyle.Plain, target: self, action: "VisitorLoginViewWillLogin")
    
    }
    
    /// 实现方法
    //点击登录
    func VisitorLoginViewWillLogin() {
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
    }
    
    //点击注册
    func VisitorLoginViewWillRegister() {
        print("注册")
    }
    
 }
